
#include "Component.h"
#include "ComponentNode.h"
#include "ComponentLeaf.h"
#include <memory>

using namespace npComposite;
using namespace std;


void doComposite()
{
    unique_ptr<ComponentNode> distructor(new ComponentNode("root"));

    //根、叶子*2
    ComponentNode* root = distructor.get();
    root->add(new ComponentLeaf("leaf_a"));
    root->add(new ComponentLeaf("leaf_b"));

    //支、叶子*2
    ComponentNode* fork1 = new ComponentNode("fork1");
    fork1->add(new ComponentLeaf("leaf_11"));
    fork1->add(new ComponentLeaf("leaf_12"));
    root->add(fork1);

    //支、叶子*2
    ComponentNode* fork2 = new ComponentNode("fork2");
    fork2->add(new ComponentLeaf("leaf_21"));
    fork2->add(new ComponentLeaf("leaf_22"));
    fork1->add(fork2);

    //支、叶子*2
    ComponentNode* fork3 = new ComponentNode("fork3");
    fork3->add(new ComponentLeaf("leaf_31"));
    fork3->add(new ComponentLeaf("leaf_32"));
    root->add(fork3);

    root->display(1);
}